package com.ops.service.ns.system.bo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import com.ops.service.ns.system.idao.IOnlinePayrollSystemDAO;
import com.ops.schema.ns.system.LoginRequest;
import com.ops.schema.ns.system.LoginResponse;
import com.ops.schema.ns.system.LogoutRequest;
import com.ops.schema.ns.system.LogoutResponse;
import com.ops.schema.ns.system.RetrieveMenuRequest;
import com.ops.schema.ns.system.RetrieveMenuResponse;
import com.ops.schema.ns.system.SearchParametersRequest;
import com.ops.schema.ns.system.UpdateEmployerRequest;
import com.ops.schema.ns.system.UpdateEmployerResponse;
import com.ops.schema.ns.system.SearchParametersRequest;
import com.ops.schema.ns.system.SearchParametersResponse;
import com.ops.schema.ns.system.UpdateParametersRequest;
import com.ops.schema.ns.system.UpdateParametersResponse;
import com.ops.schema.ns.system.SearchMessagesRequest;
import com.ops.schema.ns.system.SearchMessagesResponse;
import com.ops.schema.ns.system.UpdateMessagesRequest;
import com.ops.schema.ns.system.UpdateMessagesResponse;
import com.ops.schema.ns.system.SearchLookUpsRequest;
import com.ops.schema.ns.system.SearchLookUpsResponse;
import com.ops.schema.ns.system.UpdateLookUpsRequest;
import com.ops.schema.ns.system.UpdateLookUpsResponse;
import com.ops.schema.ns.system.SearchRulesRequest;
import com.ops.schema.ns.system.SearchRulesResponse;
import com.ops.schema.ns.system.UpdateRulesRequest;
import com.ops.schema.ns.system.UpdateRulesResponse;
import com.ops.schema.ns.system.SearchRuleBindsRequest;
import com.ops.schema.ns.system.SearchRuleBindsResponse;
import com.ops.schema.ns.system.SearchRuleRatesRequest;
import com.ops.schema.ns.system.SearchRuleRatesResponse;
import com.ops.schema.ns.system.UpdateRuleRatesRequest;
import com.ops.schema.ns.system.UpdateRuleRatesResponse;
import com.ops.schema.ns.system.SearchUserSessionsRequest;
import com.ops.schema.ns.system.SearchUserSessionsResponse;
import com.ops.schema.ns.system.SearchUsersRequest;
import com.ops.schema.ns.system.SearchUsersResponse;
import com.ops.schema.ns.system.UpdateUsersRequest;
import com.ops.schema.ns.system.UpdateUsersResponse;
import com.ops.schema.ns.system.SearchUserActionsRequest;
import com.ops.schema.ns.system.SearchUserActionsResponse;
import com.ops.schema.ns.system.SearchTaxAuthoritiesRequest;
import com.ops.schema.ns.system.SearchTaxAuthoritiesResponse;
import com.ops.schema.ns.system.UpdateTaxAuthoritiesRequest;
import com.ops.schema.ns.system.UpdateTaxAuthoritiesResponse;
import com.ops.schema.ns.system.RetrieveRolesRequest;
import com.ops.schema.ns.system.RetrieveRolesResponse;

import com.ops.schema.ns.system.OPSEmployer;
import com.ops.schema.ns.system.OPSRules;
import com.ops.schema.ns.system.OPSUser;
import com.ops.schema.ns.system.OPSRoles;
import com.ops.schema.ns.system.OPSMenu;
import com.ops.schema.ns.system.OPSRole;
import com.ops.schema.ns.system.ServiceResult;
import com.ops.schema.ns.system.OPSRecordAuditInfo;
import com.ops.schema.ns.system.OPSParameters;
import com.ops.schema.ns.system.OPSMessages;
import com.ops.schema.ns.system.OPSLookUps;
import com.ops.schema.ns.system.OPSRuleBinds;
import com.ops.schema.ns.system.OPSRuleRates;
import com.ops.schema.ns.system.OPSUserSessions;
import com.ops.schema.ns.system.OPSUserAction;
import com.ops.schema.ns.system.OPSTaxAuthority;
import com.ops.service.ns.system.exceptionhandler.ExceptionHandler;

import com.ops.service.ns.system.exception.OPSException;

public class OnlinePayrollSystemBO {
	
	private IOnlinePayrollSystemDAO dao;
	
    public void setDao(IOnlinePayrollSystemDAO dao) {
    	this.dao=dao;
    }	

    public IOnlinePayrollSystemDAO getDao() {
    	return this.dao;
    }	
	
    private static final Logger LOG_BO = Logger.getLogger(OnlinePayrollSystemBO.class.getName());
    
	 public LoginResponse login(LoginRequest parameters) throws OPSException {
		 LOG_BO.info("Inside login::BO");
		 LoginResponse response = new LoginResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 Map mpResult=dao.login(parameters.getUserId(), parameters.getPassword(), parameters.getUserSession());
		 ArrayList rs1 = (ArrayList)mpResult.get("p_user");
		 LOG_BO.info("The Values of login:"+rs1);
		 if(rs1!= null && !rs1.isEmpty()){
			 for(Object obj : rs1){
				 HashMap<String,String> mp = (HashMap<String,String>)obj;
				 OPSUser opsUser = new OPSUser();
				 auditInfo = new OPSRecordAuditInfo();
				 opsUser.setId(mp.get("userId"));
				 opsUser.setName(mp.get("userName"));
				 opsUser.setStatus(mp.get("userStatus"));
				 opsUser.setPassword(mp.get("password"));
				 
				 auditInfo.setCreatedBy(mp.get("createdBy"));
				 auditInfo.setCreatedDate(mp.get("createdDate"));
				 auditInfo.setCreatedSession(mp.get("createdSession"));
				 auditInfo.setUpdatedBy(mp.get("updatedBy"));
				 auditInfo.setUpdatedDate(mp.get("updatedDate"));
				 auditInfo.setUpdatedSession(mp.get("updatedSession"));
				 auditInfo.setDeletedBy(mp.get("deletedBy"));
				 auditInfo.setDeletedDate(mp.get("deletedDate"));
				 auditInfo.setDeletedSession(mp.get("deletedSession"));
				 
				 opsUser.setOPSRecordAuditInfo(auditInfo);
				 
				 response.setOPSUser(opsUser);
			 }
		 }
		 
		 rs1 = (ArrayList)mpResult.get("p_roles");
		 LOG_BO.info("The Values of login:"+rs1);
		 if(rs1!= null && !rs1.isEmpty()){
			 for(Object obj : rs1){
				 HashMap<String,String> mp = (HashMap<String,String>)obj;
				 OPSRole opsRole = new OPSRole();
				 auditInfo = new OPSRecordAuditInfo();
				 opsRole.setId(mp.get("roleId"));
				 opsRole.setName(mp.get("roleName"));
				 opsRole.setStatus(mp.get("roleStatus"));
				 
				 auditInfo.setCreatedBy(mp.get("createdBy"));
				 auditInfo.setCreatedDate(mp.get("createdDate"));
				 auditInfo.setCreatedSession(mp.get("createdSession"));
				 auditInfo.setUpdatedBy(mp.get("updatedBy"));
				 auditInfo.setUpdatedDate(mp.get("updatedDate"));
				 auditInfo.setUpdatedSession(mp.get("updatedSession"));
				 auditInfo.setDeletedBy(mp.get("deletedBy"));
				 auditInfo.setDeletedDate(mp.get("deletedDate"));
				 auditInfo.setDeletedSession(mp.get("deletedSession"));
				 
				 opsRole.setOPSRecordAuditInfo(auditInfo);
				 
				 response.getOPSRole().add(opsRole);
			 }
		 }
		 
		 rs1 = (ArrayList)mpResult.get("p_menu");
		 LOG_BO.info("The Values of login:"+rs1);
		 if(rs1!= null && !rs1.isEmpty()){
			 for(Object obj : rs1){
				 HashMap<String,String> mp = (HashMap<String,String>)obj;
				 OPSMenu opsMenu = new OPSMenu();
				 auditInfo = new OPSRecordAuditInfo();
				 opsMenu.setId(mp.get("menuId"));
				 opsMenu.setName(mp.get("menuName"));
				 opsMenu.setStatus(mp.get("menuStatus"));
				 opsMenu.setParentMenuId(mp.get("parentMenuId"));
				 opsMenu.setMenuClass(mp.get("menuClass"));
				 opsMenu.setDivision(mp.get("menuDivision"));
				 opsMenu.setMenuUrl(mp.get("menuURL"));
				 auditInfo.setCreatedBy(mp.get("createdBy"));
				 auditInfo.setCreatedDate(mp.get("createdDate"));
				 auditInfo.setCreatedSession(mp.get("createdSession"));
				 auditInfo.setUpdatedBy(mp.get("updatedBy"));
				 auditInfo.setUpdatedDate(mp.get("updatedDate"));
				 auditInfo.setUpdatedSession(mp.get("updatedSession"));
				 auditInfo.setDeletedBy(mp.get("deletedBy"));
				 auditInfo.setDeletedDate(mp.get("deletedDate"));
				 auditInfo.setDeletedSession(mp.get("deletedSession"));
				 
				 opsMenu.setOPSRecordAuditInfo(auditInfo);
				 
				 response.getOPSMenu().add(opsMenu);
			 }
		 }	
		 
		 ServiceResult result = new ServiceResult();
		 
		 result.setStatusCode((String)mpResult.get("pov_error_code"));
		 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
		 
		 
		 response.setServiceResult(result);
		 
		 
		 
		 return response;
	 }  
	 
	 public LogoutResponse logout(LogoutRequest parameters) throws OPSException {
		 LOG_BO.info("Inside logout::BO");
		 LogoutResponse response = new LogoutResponse();
		 Map mpResult=dao.logout(parameters.getUserId(), parameters.getUserSession());
		 ServiceResult result = new ServiceResult();
		 result.setStatusCode((String)mpResult.get("pov_error_code"));
		 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
		 response.setServiceResult(result);
		 return response;
	 } 	 
	 
	 public RetrieveMenuResponse retrieveMenu(RetrieveMenuRequest parameters) throws OPSException {
		 LOG_BO.info("Inside retrieveMenu::BO");
		 RetrieveMenuResponse response = new RetrieveMenuResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 Map mpResult=dao.retrieveMenu(parameters.getUserId(), parameters.getRoleId());
		 ArrayList rs1 = (ArrayList)mpResult.get("p_menus");
		 LOG_BO.info("The Values of retrieveMenu:"+rs1);
		 if(rs1!= null && !rs1.isEmpty()){
			 for(Object obj : rs1){
				 HashMap<String,String> mp = (HashMap<String,String>)obj;
				 OPSMenu opsMenu = new OPSMenu();
				 auditInfo = new OPSRecordAuditInfo();
				 opsMenu.setId(mp.get("menuId"));
				 opsMenu.setName(mp.get("menuName"));
				 opsMenu.setStatus(mp.get("menuStatus"));
				 opsMenu.setParentMenuId(mp.get("parentMenuId"));
				 opsMenu.setMenuClass(mp.get("menuClass"));
				 opsMenu.setDivision(mp.get("menuDivision"));
				 opsMenu.setMenuUrl(mp.get("menuURL"));
				 auditInfo.setCreatedBy(mp.get("createdBy"));
				 auditInfo.setCreatedDate(mp.get("createdDate"));
				 auditInfo.setCreatedSession(mp.get("createdSession"));
				 auditInfo.setUpdatedBy(mp.get("updatedBy"));
				 auditInfo.setUpdatedDate(mp.get("updatedDate"));
				 auditInfo.setUpdatedSession(mp.get("updatedSession"));
				 auditInfo.setDeletedBy(mp.get("deletedBy"));
				 auditInfo.setDeletedDate(mp.get("deletedDate"));
				 auditInfo.setDeletedSession(mp.get("deletedSession"));
				 
				 opsMenu.setOPSRecordAuditInfo(auditInfo);
				 
				 response.getOPSMenu().add(opsMenu);
			 }
		 }	
		 ServiceResult result = new ServiceResult();
		 
		 result.setStatusCode((String)mpResult.get("pov_error_code"));
		 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
		 
		 response.setServiceResult(result);
		 
		 return response;
	 }	 
	 
	 public void recordAction(OPSRecordAuditInfo info, String objectId) throws OPSException {
		 
		 if(info.getAction()!= null && info.getObjectType() != null && !info.getAction().equals("") && !info.getObjectType().equals("")) {
			 
			 String action = info.getAction();
			 String objectType = info.getObjectType(); 
			 String userSession = info.getUpdatedSession();
			 String userId = info.getUpdatedBy();
			 Map mpResult=dao.recordAction(action, objectType, objectId, userSession, userId);
			 LOG_BO.info("Inside recordAction::BO:pov_error_code="+mpResult.get("pov_error_code"));
		 }
	 }	 

	 public UpdateEmployerResponse updateEmployer(UpdateEmployerRequest parameters) throws OPSException {
		 LOG_BO.info("Inside updateEmployer::BO");
		 UpdateEmployerResponse response = new UpdateEmployerResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 Map mpResult=dao.updateEmployer(parameters.getOPSEmployer());
		 
		 /*ArrayList rs1 = (ArrayList)mpResult.get("employer");
		 LOG_BO.info("The Values of updateEmployer:"+rs1);
		 if(rs1!= null && !rs1.isEmpty()){
			 for(Object obj : rs1){
				 HashMap<String,String> mp = (HashMap<String,String>)obj;
				 OPSEmployer oPSEmployer = new OPSEmployer();
				 auditInfo = new OPSRecordAuditInfo();
				 oPSEmployer.setId(mp.get("employerId"));
				 oPSEmployer.setName(mp.get("employerName"));
				 oPSEmployer.setDba(mp.get("employerDBA"));
				 oPSEmployer.setAddress1(mp.get("address1"));
				 oPSEmployer.setAddress2(mp.get("address2"));
				 oPSEmployer.setCity(mp.get("city"));
				 oPSEmployer.setState(mp.get("state"));
				 oPSEmployer.setCountry(mp.get("country"));
				 oPSEmployer.setZipCode(mp.get("zipCode"));
				 oPSEmployer.setPhone(mp.get("phone"));
				 oPSEmployer.setFax(mp.get("fax"));
				 oPSEmployer.setWebsite(mp.get("website"));
				 oPSEmployer.setTaxId(mp.get("taxId"));
				 oPSEmployer.setEntityType(mp.get("entityType"));
				 oPSEmployer.setEstablishmentDate(mp.get("establishmentDate"));
				 oPSEmployer.setSicCode(mp.get("sicCode"));
				 
				 auditInfo.setCreatedBy(mp.get("createdBy"));
				 auditInfo.setCreatedDate(mp.get("createdDate"));
				 auditInfo.setCreatedSession(mp.get("createdSession"));
				 auditInfo.setUpdatedBy(mp.get("updatedBy"));
				 auditInfo.setUpdatedDate(mp.get("updatedDate"));
				 auditInfo.setUpdatedSession(mp.get("updatedSession"));
				 auditInfo.setDeletedBy(mp.get("deletedBy"));
				 auditInfo.setDeletedDate(mp.get("deletedDate"));
				 auditInfo.setDeletedSession(mp.get("deletedSession"));
				 
				 oPSEmployer.setOPSRecordAuditInfo(auditInfo);
				 
				 response.setOPSEmployer(oPSEmployer);
			 }
		 }	*/
		 
		 
		 ServiceResult result = new ServiceResult();
		 result.setStatusCode((String)mpResult.get("statusCode"));
		 result.setStatusMsg((String)mpResult.get("statusMessage"));
		 response.setServiceResult(result);
		 return response;
	 }	
	 
	 public SearchParametersResponse searchParameters(SearchParametersRequest parameters) throws OPSException {
		 LOG_BO.info("Inside searchParameters::BO");
		 SearchParametersResponse response = new SearchParametersResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 Map mpResult=dao.searchParameters(parameters.getName(), parameters.getType(), parameters.getActiveFrom(), parameters.getActiveTo());
		 ArrayList rs1 = (ArrayList)mpResult.get("p_parameters");
		 LOG_BO.info("The Values of searchParameters:"+rs1);
		 if(rs1!= null && !rs1.isEmpty()){
			 for(Object obj : rs1){
				 HashMap<String,String> mp = (HashMap<String,String>)obj;
				 OPSParameters opsParameters = new OPSParameters();
				 auditInfo = new OPSRecordAuditInfo();
				 opsParameters.setId(mp.get("parameterId"));
				 opsParameters.setName(mp.get("parameterName"));
				 opsParameters.setType(mp.get("parameterType"));
				 opsParameters.setKey(mp.get("parameterKey"));
				 opsParameters.setValue(mp.get("parameterValue"));
				 opsParameters.setActiveFrom(mp.get("activeFrom"));
				 opsParameters.setActiveTo(mp.get("activeTo"));
				 
				 auditInfo.setCreatedBy(mp.get("createdBy"));
				 auditInfo.setCreatedDate(mp.get("createdDate"));
				 auditInfo.setCreatedSession(mp.get("createdSession"));
				 auditInfo.setUpdatedBy(mp.get("updatedBy"));
				 auditInfo.setUpdatedDate(mp.get("updatedDate"));
				 auditInfo.setUpdatedSession(mp.get("updatedSession"));
				 auditInfo.setDeletedBy(mp.get("deletedBy"));
				 auditInfo.setDeletedDate(mp.get("deletedDate"));
				 auditInfo.setDeletedSession(mp.get("deletedSession"));
				 
				 opsParameters.setOPSRecordAuditInfo(auditInfo);
				 
				 response.getOPSParameters().add(opsParameters);
			 }
		 }
		 
		 ServiceResult result = new ServiceResult();
		 
		 result.setStatusCode((String)mpResult.get("pov_error_code"));
		 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
		 
		 
		 response.setServiceResult(result);
		 
		 recordAction(parameters.getOPSRecordAuditInfo(), null);
		 
		 return response;
	 } 	
	 
	 public UpdateParametersResponse updateParameters(UpdateParametersRequest parameters) throws OPSException {
		 LOG_BO.info("Inside updateParameters::BO");
		 UpdateParametersResponse response = new UpdateParametersResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 OPSParameters opsParameters = null;
		 ServiceResult result = new ServiceResult();
		 Map mpResult = null;
		 for(OPSParameters parameter: parameters.getOPSParameters()) {
			 mpResult = dao.updateParameters(parameter.getId(), parameter.getName(), parameter.getType(), parameter.getValue(), parameter.getKey(), parameter.getActiveFrom(), parameter.getActiveTo(), parameter.getOPSRecordAuditInfo().getUpdatedBy(), parameter.getOPSRecordAuditInfo().getUpdatedSession(), parameter.getOperationFlag());
			 if(!(mpResult.get("pov_error_code") != null && ((String)mpResult.get("pov_error_code")).equals("0000"))) {
				 result.setStatusCode((String)mpResult.get("pov_error_code"));
				 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
			 } else if(result.getStatusCode() == null) {
				 result.setStatusCode((String)mpResult.get("pov_error_code"));
				 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
			 }
			 recordAction(parameter.getOPSRecordAuditInfo(), parameter.getId());		 
		 } 
		 
		 response.setServiceResult(result);
		 
		 
		 return response;
	 } 	 
	 
	 public SearchMessagesResponse searchMessages(SearchMessagesRequest parameters) throws OPSException {
		 LOG_BO.info("Inside searchMessages::BO");
		 SearchMessagesResponse response = new SearchMessagesResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 Map mpResult=dao.searchMessages(parameters.getName(), parameters.getLang(), parameters.getActiveFrom(), parameters.getActiveTo());
		 ArrayList rs1 = (ArrayList)mpResult.get("p_messages");
		 LOG_BO.info("The Values of searchMessages:"+rs1);
		 if(rs1!= null && !rs1.isEmpty()){
			 for(Object obj : rs1){
				 HashMap<String,String> mp = (HashMap<String,String>)obj;
				 OPSMessages opsMessages = new OPSMessages();
				 auditInfo = new OPSRecordAuditInfo();
				 opsMessages.setId(mp.get("MESSAGE_ID"));
				 opsMessages.setLang(mp.get("MESSAGE_LANG"));
				 opsMessages.setKey(mp.get("MESSAGE_KEY"));
				 opsMessages.setName(mp.get("MESSAGE_NAME"));
				 opsMessages.setValue(mp.get("PARAMETER_VALUE"));
				 opsMessages.setActiveFrom(mp.get("START_DATE_ACTIVE"));
				 opsMessages.setActiveTo(mp.get("END_DATE_ACTIVE"));
				 
				 auditInfo.setCreatedBy(mp.get("createdBy"));
				 auditInfo.setCreatedDate(mp.get("createdDate"));
				 auditInfo.setCreatedSession(mp.get("createdSession"));
				 auditInfo.setUpdatedBy(mp.get("updatedBy"));
				 auditInfo.setUpdatedDate(mp.get("updatedDate"));
				 auditInfo.setUpdatedSession(mp.get("updatedSession"));
				 auditInfo.setDeletedBy(mp.get("deletedBy"));
				 auditInfo.setDeletedDate(mp.get("deletedDate"));
				 auditInfo.setDeletedSession(mp.get("deletedSession"));
				 
				 opsMessages.setOPSRecordAuditInfo(auditInfo);
				 
				 response.getOPSMessages().add(opsMessages);
			 }
		 }
		 
		 ServiceResult result = new ServiceResult();
		 
		 result.setStatusCode((String)mpResult.get("pov_error_code"));
		 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
		 
		 
		 response.setServiceResult(result);
		 
		 recordAction(parameters.getOPSRecordAuditInfo(), null);
		 
		 return response;
	 } 	
	 
	 public UpdateMessagesResponse updateMessages(UpdateMessagesRequest parameters) throws OPSException {
		 LOG_BO.info("Inside updateMessages::BO");
		 UpdateMessagesResponse response = new UpdateMessagesResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 ServiceResult result = new ServiceResult();
		 Map mpResult = null;
		 for(OPSMessages parameter: parameters.getOPSMessages()) {
			 mpResult = dao.updateMessages(parameter.getId(), parameter.getName(), parameter.getLang(), parameter.getKey(), parameter.getValue(),  parameter.getActiveFrom(), parameter.getActiveTo(), parameter.getOPSRecordAuditInfo().getUpdatedBy(), parameter.getOPSRecordAuditInfo().getUpdatedSession(), parameter.getOperationFlag());
			 if(!(mpResult.get("pov_error_code") != null && ((String)mpResult.get("pov_error_code")).equals("0000"))) {
				 result.setStatusCode((String)mpResult.get("pov_error_code"));
				 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
			 } else if(result.getStatusCode() == null) {
				 result.setStatusCode((String)mpResult.get("pov_error_code"));
				 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
			 }
			 recordAction(parameter.getOPSRecordAuditInfo(), parameter.getId());		 
		 } 
		 
		 response.setServiceResult(result);
		 
		 return response;
	 } 	 
	 
	 public SearchLookUpsResponse searchLookups(SearchLookUpsRequest parameters) throws OPSException {
		 LOG_BO.info("Inside searchLookups::BO");
		 SearchLookUpsResponse response = new SearchLookUpsResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 Map mpResult=dao.searchLookups(parameters.getName(), parameters.getType(), parameters.getActiveFrom(), parameters.getActiveTo());
		 ArrayList rs1 = (ArrayList)mpResult.get("p_lookups");
		 LOG_BO.info("The Values of searchLookups:"+rs1);
		 if(rs1!= null && !rs1.isEmpty()){
			 for(Object obj : rs1){
				 HashMap<String,String> mp = (HashMap<String,String>)obj;
				 OPSLookUps opsLookUps = new OPSLookUps();
				 auditInfo = new OPSRecordAuditInfo();
				 opsLookUps.setId(mp.get("LOOKUP_ID"));
				 opsLookUps.setType(mp.get("LOOKUP_TYPE"));
				 opsLookUps.setName(mp.get("LOOKUP_VALUE_NAME"));
				 opsLookUps.setCode(mp.get("LOOKUP_VALUE_KEY"));
				 opsLookUps.setDescription(mp.get("LOOKUP_VALUE_DESCRIPTION"));
				 opsLookUps.setAssociatedRuleId(mp.get("ASSOCIATED_RULE"));
				 opsLookUps.setActiveFrom(mp.get("START_DATE_ACTIVE"));
				 opsLookUps.setActiveTo(mp.get("END_DATE_ACTIVE"));
				 
				 auditInfo.setCreatedBy(mp.get("createdBy"));
				 auditInfo.setCreatedDate(mp.get("createdDate"));
				 auditInfo.setCreatedSession(mp.get("createdSession"));
				 auditInfo.setUpdatedBy(mp.get("updatedBy"));
				 auditInfo.setUpdatedDate(mp.get("updatedDate"));
				 auditInfo.setUpdatedSession(mp.get("updatedSession"));
				 auditInfo.setDeletedBy(mp.get("deletedBy"));
				 auditInfo.setDeletedDate(mp.get("deletedDate"));
				 auditInfo.setDeletedSession(mp.get("deletedSession"));
				 
				 opsLookUps.setOPSRecordAuditInfo(auditInfo);
				 
				 response.getOPSLookUps().add(opsLookUps);
			 }
		 }
		 
		 ServiceResult result = new ServiceResult();
		 
		 result.setStatusCode((String)mpResult.get("pov_error_code"));
		 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
		 
		 
		 response.setServiceResult(result);
		 
		 recordAction(parameters.getOPSRecordAuditInfo(), null);
		 
		 return response;
	 } 	
	 
	 public UpdateLookUpsResponse updateLookups(UpdateLookUpsRequest parameters) throws OPSException {
		 LOG_BO.info("Inside updateLookups::BO");
		 UpdateLookUpsResponse response = new UpdateLookUpsResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 ServiceResult result = new ServiceResult();
		 Map mpResult = null;
		 for(OPSLookUps parameter: parameters.getOPSLookUps()) {
			 mpResult = dao.updateLookups(parameter.getId(), parameter.getType(), parameter.getName(), parameter.getCode(), parameter.getDescription(),  parameter.getAssociatedRuleId(), parameter.getActiveFrom(), parameter.getActiveTo(), parameter.getOPSRecordAuditInfo().getUpdatedBy(), parameter.getOPSRecordAuditInfo().getUpdatedSession(), parameter.getOperationFlag());
			 if(!(mpResult.get("pov_error_code") != null && ((String)mpResult.get("pov_error_code")).equals("0000"))) {
				 result.setStatusCode((String)mpResult.get("pov_error_code"));
				 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
			 } else if(result.getStatusCode() == null) {
				 result.setStatusCode((String)mpResult.get("pov_error_code"));
				 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
			 }
			 recordAction(parameter.getOPSRecordAuditInfo(), parameter.getId());		 
		 } 
		 
		 response.setServiceResult(result);
		 
		 return response;
	 } 	
	 
	 public SearchRulesResponse searchRules(SearchRulesRequest parameters) throws OPSException {
		 LOG_BO.info("Inside searchRules::BO");
		 SearchRulesResponse response = new SearchRulesResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 Map mpResult=dao.searchRules(parameters.getRuleName(), parameters.getRuleType(), parameters.getRuleGroup(), parameters.getDataType(), parameters.getActiveFrom(), parameters.getActiveTo());
		 ArrayList rs1 = (ArrayList)mpResult.get("p_rules");
		 LOG_BO.info("The Values of searchRules:"+rs1);
		 if(rs1!= null && !rs1.isEmpty()){
			 for(Object obj : rs1){
				 HashMap<String,String> mp = (HashMap<String,String>)obj;
				 OPSRules opsRules = new OPSRules();
				 auditInfo = new OPSRecordAuditInfo();
				 opsRules.setId(mp.get("RULE_ID"));
				 opsRules.setRuleGroup(mp.get("RULE_GROUP"));
				 opsRules.setRuleName(mp.get("RULE_NAME"));
				 opsRules.setDescription(mp.get("RULE_DESCRIPTION"));
				 opsRules.setRuleType(mp.get("RULE_TYPE"));
				 opsRules.setDataType(mp.get("RULE_DATATYPE"));
				 opsRules.setCalcType(mp.get("CALC_TYPE"));
				 opsRules.setFormula(mp.get("RULE_FORMULA"));
				 opsRules.setParameters(mp.get("RULE_PARAMS"));
				 opsRules.setFilter(mp.get("RULE_FILTER"));
				 opsRules.setRate(mp.get("RULE_RATE"));
				 opsRules.setLevel(mp.get("RULE_LEVEL"));
				 opsRules.setValueFormat(mp.get("VALUE_FORMAT"));
				 opsRules.setRequired(mp.get("IS_REQUIRED"));
				 opsRules.setActiveFrom(mp.get("START_DATE_ACTIVE"));
				 opsRules.setActiveTo(mp.get("END_DATE_ACTIVE"));
				 
				 auditInfo.setCreatedBy(mp.get("createdBy"));
				 auditInfo.setCreatedDate(mp.get("createdDate"));
				 auditInfo.setCreatedSession(mp.get("createdSession"));
				 auditInfo.setUpdatedBy(mp.get("updatedBy"));
				 auditInfo.setUpdatedDate(mp.get("updatedDate"));
				 auditInfo.setUpdatedSession(mp.get("updatedSession"));
				 auditInfo.setDeletedBy(mp.get("deletedBy"));
				 auditInfo.setDeletedDate(mp.get("deletedDate"));
				 auditInfo.setDeletedSession(mp.get("deletedSession"));
				 
				 opsRules.setOPSRecordAuditInfo(auditInfo);
				 
				 response.getOPSRules().add(opsRules);
			 }
		 }
		 
		 ServiceResult result = new ServiceResult();
		 
		 result.setStatusCode((String)mpResult.get("pov_error_code"));
		 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
		 
		 
		 response.setServiceResult(result);
		 
		 recordAction(parameters.getOPSRecordAuditInfo(), null);
		 
		 return response;
	 } 	
	 
	 public UpdateRulesResponse updateRules(UpdateRulesRequest parameters) throws OPSException {
		 LOG_BO.info("Inside updateRules::BO");
		 UpdateRulesResponse response = new UpdateRulesResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 ServiceResult result = new ServiceResult();
		 Map mpResult = null;
		 for(OPSRules parameter: parameters.getOPSRules()) {
			 mpResult = dao.updateRules(parameter.getId(), parameter.getRuleGroup(), parameter.getRuleName(), parameter.getDescription(), parameter.getRuleType(),  parameter.getDataType(), parameter.getCalcType(), parameter.getFormula(), parameter.getParameters(), parameter.getFilter(), parameter.getRate(), parameter.getLevel(), parameter.getValueFormat(), parameter.getRequired(),parameter.getActiveFrom(), parameter.getActiveTo(), parameter.getOPSRecordAuditInfo().getUpdatedBy(), parameter.getOPSRecordAuditInfo().getUpdatedSession(), parameter.getOperationFlag());
			 if(!(mpResult.get("pov_error_code") != null && ((String)mpResult.get("pov_error_code")).equals("0000"))) {
				 result.setStatusCode((String)mpResult.get("pov_error_code"));
				 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
			 } else if(result.getStatusCode() == null) {
				 result.setStatusCode((String)mpResult.get("pov_error_code"));
				 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
			 }
			 recordAction(parameter.getOPSRecordAuditInfo(), parameter.getId());		 
		 } 
		 
		 response.setServiceResult(result);
		 
		 return response;
	 } 	
	 
	 public SearchRuleBindsResponse searchRuleBinds(SearchRuleBindsRequest parameters) throws OPSException {
		 LOG_BO.info("Inside searchRuleBinds::BO");
		 SearchRuleBindsResponse response = new SearchRuleBindsResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 Map mpResult=dao.searchRuleBinds(parameters.getRuleName(), parameters.getBindVariable(), parameters.getBindType(), parameters.getRuleLevel());
		 ArrayList rs1 = (ArrayList)mpResult.get("p_binds");
		 LOG_BO.info("The Values of searchRuleBinds:"+rs1);
		 if(rs1!= null && !rs1.isEmpty()){
			 for(Object obj : rs1){
				 HashMap<String,String> mp = (HashMap<String,String>)obj;
				 OPSRuleBinds opsRuleBinds = new OPSRuleBinds();
				 auditInfo = new OPSRecordAuditInfo();
				 opsRuleBinds.setBindId(mp.get("RULEBIND_ID"));
				 opsRuleBinds.setRuleName(mp.get("RULE_NAME"));
				 opsRuleBinds.setBindVariable(mp.get("BIND_VAR"));
				 opsRuleBinds.setBindType(mp.get("BIND_TYPE"));
				 opsRuleBinds.setBindValue(mp.get("BIND_VALUE"));
				 opsRuleBinds.setRuleLevel(mp.get("RULE_LEVEL"));
				 
				 auditInfo.setCreatedBy(mp.get("createdBy"));
				 auditInfo.setCreatedDate(mp.get("createdDate"));
				 auditInfo.setCreatedSession(mp.get("createdSession"));
				 auditInfo.setUpdatedBy(mp.get("updatedBy"));
				 auditInfo.setUpdatedDate(mp.get("updatedDate"));
				 auditInfo.setUpdatedSession(mp.get("updatedSession"));
				 auditInfo.setDeletedBy(mp.get("deletedBy"));
				 auditInfo.setDeletedDate(mp.get("deletedDate"));
				 auditInfo.setDeletedSession(mp.get("deletedSession"));
				 
				 opsRuleBinds.setOPSRecordAuditInfo(auditInfo);
				 
				 response.getOPSRuleBinds().add(opsRuleBinds);
			 }
		 }
		 
		 ServiceResult result = new ServiceResult();
		 
		 result.setStatusCode((String)mpResult.get("pov_error_code"));
		 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
		 
		 
		 response.setServiceResult(result);
		 
		 recordAction(parameters.getOPSRecordAuditInfo(), null);
		 
		 return response;
	 } 	 
	 
	 public SearchRuleRatesResponse searchRuleRates(SearchRuleRatesRequest parameters) throws OPSException {
		 LOG_BO.info("Inside searchRuleRates::BO");
		 SearchRuleRatesResponse response = new SearchRuleRatesResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 Map mpResult=dao.searchRuleRates(parameters.getRuleName(), parameters.getTaxAuthority(), parameters.getTaxType(), parameters.getRateType());
		 ArrayList rs1 = (ArrayList)mpResult.get("p_rates");
		 LOG_BO.info("The Values of searchRuleRates:"+rs1);
		 if(rs1!= null && !rs1.isEmpty()){
			 for(Object obj : rs1){
				 HashMap<String,String> mp = (HashMap<String,String>)obj;
				 OPSRuleRates opsRuleRates = new OPSRuleRates();
				 auditInfo = new OPSRecordAuditInfo();
				 opsRuleRates.setRateId(mp.get("RATE_ID"));
				 opsRuleRates.setRuleName(mp.get("RANGE_RULE_NAME"));
				 opsRuleRates.setTaxAuthority(mp.get("TAX_AUTHORITY"));
				 opsRuleRates.setTaxType(mp.get("TAX_TYPE"));
				 opsRuleRates.setRateType(mp.get("RATE_TYPE"));
				 opsRuleRates.setParentRateId(mp.get("PARENT_RATE_ID"));
				 
				 auditInfo.setCreatedBy(mp.get("createdBy"));
				 auditInfo.setCreatedDate(mp.get("createdDate"));
				 auditInfo.setCreatedSession(mp.get("createdSession"));
				 auditInfo.setUpdatedBy(mp.get("updatedBy"));
				 auditInfo.setUpdatedDate(mp.get("updatedDate"));
				 auditInfo.setUpdatedSession(mp.get("updatedSession"));
				 auditInfo.setDeletedBy(mp.get("deletedBy"));
				 auditInfo.setDeletedDate(mp.get("deletedDate"));
				 auditInfo.setDeletedSession(mp.get("deletedSession"));
				 
				 opsRuleRates.setOPSRecordAuditInfo(auditInfo);
				 
				 response.getOPSRuleRates().add(opsRuleRates);
			 }
		 }
		 
		 ServiceResult result = new ServiceResult();
		 
		 result.setStatusCode((String)mpResult.get("pov_error_code"));
		 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
		 
		 
		 response.setServiceResult(result);
		 
		 recordAction(parameters.getOPSRecordAuditInfo(), null);
		 
		 return response;
	 } 	
	 
	 public UpdateRuleRatesResponse updateRuleRates(UpdateRuleRatesRequest parameters) throws OPSException {
		 LOG_BO.info("Inside updateRuleRates::BO");
		 UpdateRuleRatesResponse response = new UpdateRuleRatesResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 ServiceResult result = new ServiceResult();
		 Map mpResult = null;
		 for(OPSRuleRates parameter: parameters.getOPSRuleRates()) {
			 mpResult = dao.updateRuleRates(parameter.getRateId(), parameter.getRuleName(), parameter.getTaxAuthority(), parameter.getTaxType(), parameter.getRateType(),  parameter.getParentRateId(), parameter.getOPSRecordAuditInfo().getUpdatedBy(), parameter.getOPSRecordAuditInfo().getUpdatedSession(), parameter.getOperationFlag());
			 if(!(mpResult.get("pov_error_code") != null && ((String)mpResult.get("pov_error_code")).equals("0000"))) {
				 result.setStatusCode((String)mpResult.get("pov_error_code"));
				 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
			 } else if(result.getStatusCode() == null) {
				 result.setStatusCode((String)mpResult.get("pov_error_code"));
				 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
			 }
			 recordAction(parameter.getOPSRecordAuditInfo(), parameter.getRateId());		 
		 } 
		 
		 response.setServiceResult(result);
		 
		 return response;
	 } 		 
	 
	 public SearchUserSessionsResponse searchUserSessions(SearchUserSessionsRequest parameters) throws OPSException {
		 LOG_BO.info("Inside searchUserSessions::BO");
		 SearchUserSessionsResponse response = new SearchUserSessionsResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 Map mpResult=dao.searchUserSessions(parameters.getUserId(), parameters.getSessionStartTime(), parameters.getSessionEndTime());
		 ArrayList rs1 = (ArrayList)mpResult.get("p_user_sessions");
		 LOG_BO.info("The Values of searchUserSessions:"+rs1);
		 if(rs1!= null && !rs1.isEmpty()){
			 for(Object obj : rs1){
				 HashMap<String,String> mp = (HashMap<String,String>)obj;
				 OPSUserSessions opsUserSessions = new OPSUserSessions();
				 auditInfo = new OPSRecordAuditInfo();
				 opsUserSessions.setId(mp.get("USER_SESSION_ID"));
				 opsUserSessions.setUserId(mp.get("USER_ID"));
				 opsUserSessions.setLoginTime(mp.get("LOGIN_TIME"));
				 opsUserSessions.setLogoutTime(mp.get("LOGOUT_TIME"));
				 
				 auditInfo.setCreatedBy(mp.get("createdBy"));
				 auditInfo.setCreatedDate(mp.get("createdDate"));
				 auditInfo.setCreatedSession(mp.get("createdSession"));
				 auditInfo.setUpdatedBy(mp.get("updatedBy"));
				 auditInfo.setUpdatedDate(mp.get("updatedDate"));
				 auditInfo.setUpdatedSession(mp.get("updatedSession"));
				 auditInfo.setDeletedBy(mp.get("deletedBy"));
				 auditInfo.setDeletedDate(mp.get("deletedDate"));
				 auditInfo.setDeletedSession(mp.get("deletedSession"));
				 
				 opsUserSessions.setOPSRecordAuditInfo(auditInfo);
				 
				 response.getOPSUserSessions().add(opsUserSessions);
			 }
		 }
		 
		 ServiceResult result = new ServiceResult();
		 
		 result.setStatusCode((String)mpResult.get("pov_error_code"));
		 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
		 
		 
		 response.setServiceResult(result);
		 
		 recordAction(parameters.getOPSRecordAuditInfo(), null);
		 
		 return response;
	 } 	
	 
	 
	 public SearchUsersResponse searchUsers(SearchUsersRequest parameters) throws OPSException {
		 LOG_BO.info("Inside searchUsers::BO");
		 SearchUsersResponse response = new SearchUsersResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 Map mpResult=dao.searchUsers(parameters.getName(), parameters.getStatus());
		 ArrayList rs1 = (ArrayList)mpResult.get("p_users");
		 ArrayList roles = (ArrayList)mpResult.get("p_roles");
		 LOG_BO.info("The Values of searchUsers:"+rs1);
		 if(rs1!= null && !rs1.isEmpty()){
			 for(Object obj : rs1){
				 HashMap<String,String> mp = (HashMap<String,String>)obj;
				 OPSUser opsUser = new OPSUser();
				 auditInfo = new OPSRecordAuditInfo();
				 opsUser.setId(mp.get("USER_ID"));
				 opsUser.setName(mp.get("USER_NAME"));
				 opsUser.setStatus(mp.get("USER_STATUS"));
				 
				 auditInfo.setCreatedBy(mp.get("createdBy"));
				 auditInfo.setCreatedDate(mp.get("createdDate"));
				 auditInfo.setCreatedSession(mp.get("createdSession"));
				 auditInfo.setUpdatedBy(mp.get("updatedBy"));
				 auditInfo.setUpdatedDate(mp.get("updatedDate"));
				 auditInfo.setUpdatedSession(mp.get("updatedSession"));
				 auditInfo.setDeletedBy(mp.get("deletedBy"));
				 auditInfo.setDeletedDate(mp.get("deletedDate"));
				 auditInfo.setDeletedSession(mp.get("deletedSession"));
				 
				 opsUser.setOPSRecordAuditInfo(auditInfo);
				 
				 if(roles!= null && !roles.isEmpty()){
					 for(Object objRoles : roles){
						 HashMap<String,String> mpRoles = (HashMap<String,String>)objRoles;						 
						 if(mp.get("USER_ID").equals(mpRoles.get("USER_ID"))) {						 
							 OPSRoles opsRoles = new OPSRoles();
							 auditInfo = new OPSRecordAuditInfo();
							 opsRoles.setId(mpRoles.get("ROLE_ID"));
							 opsRoles.setActiveFrom(mpRoles.get("START_DATE_ACTIVE"));
							 opsRoles.setActiveTo(mpRoles.get("END_DATE_ACTIVE"));
							 
							 auditInfo.setCreatedBy(mpRoles.get("createdBy"));
							 auditInfo.setCreatedDate(mpRoles.get("createdDate"));
							 auditInfo.setCreatedSession(mpRoles.get("createdSession"));
							 auditInfo.setUpdatedBy(mpRoles.get("updatedBy"));
							 auditInfo.setUpdatedDate(mpRoles.get("updatedDate"));
							 auditInfo.setUpdatedSession(mpRoles.get("updatedSession"));
							 auditInfo.setDeletedBy(mpRoles.get("deletedBy"));
							 auditInfo.setDeletedDate(mpRoles.get("deletedDate"));
							 auditInfo.setDeletedSession(mpRoles.get("deletedSession"));
							 
							 opsRoles.setOPSRecordAuditInfo(auditInfo);
							 opsUser.getOPSRoles().add(opsRoles);
						 }
					 }
				 }				 
				 
				 
				 response.getOPSUser().add(opsUser);
			 }
		 }
		 
		 ServiceResult result = new ServiceResult();
		 
		 result.setStatusCode((String)mpResult.get("pov_error_code"));
		 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
		 
		 
		 response.setServiceResult(result);
		 
		 recordAction(parameters.getOPSRecordAuditInfo(), null);
		 
		 return response;
	 } 	
	 
	 public UpdateUsersResponse updateUsers(UpdateUsersRequest parameters) throws OPSException {
		 LOG_BO.info("Inside updateUsers::BO");
		 UpdateUsersResponse response = new UpdateUsersResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 ServiceResult result = new ServiceResult();
		 Map mpResult = null;
		 for(OPSUser parameter: parameters.getOPSUser()) {
			 mpResult = dao.updateUsers(parameter.getId(), parameter.getName(), parameter.getStatus(), parameter.getPassword(),  parameter.getOPSRecordAuditInfo().getUpdatedBy(), parameter.getOPSRecordAuditInfo().getUpdatedSession(), parameter.getOperationFlag());
			 if(!(mpResult.get("pov_error_code") != null && ((String)mpResult.get("pov_error_code")).equals("0000"))) {
				 result.setStatusCode((String)mpResult.get("pov_error_code"));
				 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
			 } else {
				 String userId = (String)mpResult.get("po_user_id");
				 for(OPSRoles role: parameter.getOPSRoles()) {
					 mpResult = dao.updateRoles(userId, role.getId(), role.getActiveFrom(), role.getActiveTo(), role.getOPSRecordAuditInfo().getUpdatedBy(), role.getOPSRecordAuditInfo().getUpdatedSession());
					 result.setStatusCode((String)mpResult.get("pov_error_code"));
					 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
				 }
			 }
			 recordAction(parameter.getOPSRecordAuditInfo(), parameter.getId());
		 } 
		 
		 response.setServiceResult(result);
		 
		 return response;
	 }
	 
	 public SearchUserActionsResponse searchUserActions(SearchUserActionsRequest parameters) throws OPSException {
		 LOG_BO.info("Inside searchUserActions::BO");
		 SearchUserActionsResponse response = new SearchUserActionsResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 Map mpResult=dao.searchUserActions(parameters.getAction(), parameters.getUser(), parameters.getObjectType(), parameters.getActionFromDate(), parameters.getActionToDate());
		 ArrayList rs1 = (ArrayList)mpResult.get("p_user_actions");
		 LOG_BO.info("The Values of searchUserActions:"+rs1);
		 if(rs1!= null && !rs1.isEmpty()){
			 for(Object obj : rs1){
				 HashMap<String,String> mp = (HashMap<String,String>)obj;
				 OPSUserAction opsUserAction = new OPSUserAction();
				 auditInfo = new OPSRecordAuditInfo();
				 opsUserAction.setUserActionId(mp.get("USER_ACTION_ID"));
				 opsUserAction.setUserSessionId(mp.get("USER_SESSION_ID"));
				 opsUserAction.setAction(mp.get("ACTION"));
				 opsUserAction.setObjectType(mp.get("OBJECT_TYPE"));
				 opsUserAction.setObjectId(mp.get("OBJECT_ID"));
				 opsUserAction.setActionDate(mp.get("ACTION_DATE"));
				 
				 auditInfo.setCreatedBy(mp.get("createdBy"));
				 auditInfo.setCreatedDate(mp.get("createdDate"));
				 auditInfo.setCreatedSession(mp.get("createdSession"));
				 auditInfo.setUpdatedBy(mp.get("updatedBy"));
				 auditInfo.setUpdatedDate(mp.get("updatedDate"));
				 auditInfo.setUpdatedSession(mp.get("updatedSession"));
				 auditInfo.setDeletedBy(mp.get("deletedBy"));
				 auditInfo.setDeletedDate(mp.get("deletedDate"));
				 auditInfo.setDeletedSession(mp.get("deletedSession"));
				 
				 opsUserAction.setOPSRecordAuditInfo(auditInfo);
				 
				 response.getOPSUserAction().add(opsUserAction);
			 }
		 }
		 
		 ServiceResult result = new ServiceResult();
		 
		 result.setStatusCode((String)mpResult.get("pov_error_code"));
		 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
		 
		 
		 response.setServiceResult(result);
		 
		 /*recordAction(parameters.getOPSRecordAuditInfo(), null);*/
		 
		 return response;
	 } 	
	 
	 public SearchTaxAuthoritiesResponse searchTaxAuthorities(SearchTaxAuthoritiesRequest parameters) throws OPSException {
		 LOG_BO.info("Inside SearchTaxAuthoritiesResponse::BO");
		 SearchTaxAuthoritiesResponse response = new SearchTaxAuthoritiesResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 Map mpResult=dao.searchTaxAuthorities(parameters.getTaxAuth(), parameters.getTaxType(), parameters.getRateType(), parameters.getRuleGroup(), parameters.getActionFrom(), parameters.getActionTo());
		 ArrayList rs1 = (ArrayList)mpResult.get("p_tax_authority");
		 LOG_BO.info("The Values of SearchTaxAuthoritiesResponse:"+rs1);
		 if(rs1!= null && !rs1.isEmpty()){
			 for(Object obj : rs1){
				 HashMap<String,String> mp = (HashMap<String,String>)obj;
				 OPSTaxAuthority opsTaxAuthority = new OPSTaxAuthority();
				 auditInfo = new OPSRecordAuditInfo();
				 opsTaxAuthority.setId(mp.get("TAXAUTHORITY_ID"));
				 opsTaxAuthority.setName(mp.get("TAX_AUTHORITY"));
				 opsTaxAuthority.setTaxType(mp.get("TAX_TYPE"));
				 opsTaxAuthority.setRateType(mp.get("RATE_TYPE"));
				 opsTaxAuthority.setAddress1(mp.get("ADDRESS1"));
				 opsTaxAuthority.setAddress2(mp.get("ADDRESS2"));
				 opsTaxAuthority.setCity(mp.get("CITY"));
				 opsTaxAuthority.setState(mp.get("STATE"));
				 opsTaxAuthority.setCountry(mp.get("COUNTRY"));
				 opsTaxAuthority.setZip(mp.get("ZIPCODE"));
				 opsTaxAuthority.setRuleGroup(mp.get("RULE_GROUP"));
				 opsTaxAuthority.setActiveFrom(mp.get("START_DATE_ACTIVE"));
				 opsTaxAuthority.setActiveTo(mp.get("END_DATE_ACTIVE"));
				 
				 auditInfo.setCreatedBy(mp.get("createdBy"));
				 auditInfo.setCreatedDate(mp.get("createdDate"));
				 auditInfo.setCreatedSession(mp.get("createdSession"));
				 auditInfo.setUpdatedBy(mp.get("updatedBy"));
				 auditInfo.setUpdatedDate(mp.get("updatedDate"));
				 auditInfo.setUpdatedSession(mp.get("updatedSession"));
				 auditInfo.setDeletedBy(mp.get("deletedBy"));
				 auditInfo.setDeletedDate(mp.get("deletedDate"));
				 auditInfo.setDeletedSession(mp.get("deletedSession"));
				 
				 opsTaxAuthority.setOPSRecordAuditInfo(auditInfo);
				 
				 response.getOPSTaxAuthority().add(opsTaxAuthority);
			 }
		 }
		 
		 ServiceResult result = new ServiceResult();
		 
		 result.setStatusCode((String)mpResult.get("pov_error_code"));
		 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
		 
		 
		 response.setServiceResult(result);
		 
		 recordAction(parameters.getOPSRecordAuditInfo(), null);
		 
		 return response;
	 } 		 
	 
	 public UpdateTaxAuthoritiesResponse updateTaxAuthorities(UpdateTaxAuthoritiesRequest parameters) throws OPSException {
		 LOG_BO.info("Inside updateUsers::BO");
		 UpdateTaxAuthoritiesResponse response = new UpdateTaxAuthoritiesResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 ServiceResult result = new ServiceResult();
		 Map mpResult = null;
		 for(OPSTaxAuthority parameter: parameters.getOPSTaxAuthority()) {
			 mpResult = dao.updateTaxAuthorities(parameter.getId(), parameter.getName(), parameter.getTaxType(), parameter.getRateType(), parameter.getAddress1(), parameter.getAddress2(), parameter.getCity(), parameter.getState(), parameter.getCountry(), parameter.getZip(), parameter.getRuleGroup(), parameter.getActiveFrom(), parameter.getActiveTo(),  parameter.getOPSRecordAuditInfo().getUpdatedBy(), parameter.getOPSRecordAuditInfo().getUpdatedSession(), parameter.getOperationFlag());
			 if(!(mpResult.get("pov_error_code") != null && ((String)mpResult.get("pov_error_code")).equals("0000"))) {
				 result.setStatusCode((String)mpResult.get("pov_error_code"));
				 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
			 } else if(result.getStatusCode() == null) {
				 result.setStatusCode((String)mpResult.get("pov_error_code"));
				 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
			 }
			 recordAction(parameter.getOPSRecordAuditInfo(), parameter.getId());
		 } 
		 
		 response.setServiceResult(result);
		 
		 return response;
	 }
	 
	 public RetrieveRolesResponse retrieveRoles(RetrieveRolesRequest parameters) throws OPSException {
		 LOG_BO.info("Inside RetrieveRolesResponse::BO");
		 RetrieveRolesResponse response = new RetrieveRolesResponse();
		 OPSRecordAuditInfo auditInfo = null;
		 Map mpResult=dao.retrieveRoles(parameters.getName(), parameters.getActiveFrom(), parameters.getActiveTo());
		 ArrayList rs1 = (ArrayList)mpResult.get("p_roles");
		 LOG_BO.info("The Values of RetrieveRolesResponse:"+rs1);
		 if(rs1!= null && !rs1.isEmpty()){
			 for(Object obj : rs1){
				 HashMap<String,String> mp = (HashMap<String,String>)obj;
				 OPSRoles opsRoles = new OPSRoles();
				 auditInfo = new OPSRecordAuditInfo();
				 opsRoles.setId(mp.get("ROLE_ID"));
				 opsRoles.setName(mp.get("ROLE_NAME"));
				 opsRoles.setActiveFrom(mp.get("START_DATE_ACTIVE"));
				 opsRoles.setActiveTo(mp.get("END_DATE_ACTIVE"));
				 
				 auditInfo.setCreatedBy(mp.get("createdBy"));
				 auditInfo.setCreatedDate(mp.get("createdDate"));
				 auditInfo.setCreatedSession(mp.get("createdSession"));
				 auditInfo.setUpdatedBy(mp.get("updatedBy"));
				 auditInfo.setUpdatedDate(mp.get("updatedDate"));
				 auditInfo.setUpdatedSession(mp.get("updatedSession"));
				 auditInfo.setDeletedBy(mp.get("deletedBy"));
				 auditInfo.setDeletedDate(mp.get("deletedDate"));
				 auditInfo.setDeletedSession(mp.get("deletedSession"));
				 
				 opsRoles.setOPSRecordAuditInfo(auditInfo);
				 
				 response.getOPSRoles().add(opsRoles);
			 }
		 }
		 
		 ServiceResult result = new ServiceResult();
		 
		 result.setStatusCode((String)mpResult.get("pov_error_code"));
		 result.setStatusMsg((String)mpResult.get("pov_error_msg"));
		 
		 
		 response.setServiceResult(result);
		 
		 recordAction(parameters.getOPSRecordAuditInfo(), null);
		 
		 return response;
	 } 	 
}
